package com.cy.com.cy.pj.arithmetic.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ArithmeticController {
    @RequestMapping("doCompute/{n1}/{n2}")
    @ResponseBody
    public String doCompute(@PathVariable  Integer n1,
                            @PathVariable Integer n2){
        try{
            Integer result=n1/n2;
            return "Result is "+result;
        }catch(ArithmeticException e){
            return "exception is "+e.getMessage();
        }
    }
}
